import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { UndrawUiResolver } from 'undraw-ui/es/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
      vue(),
      Components({
      resolvers: [UndrawUiResolver]
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
   server: {
    host: '0.0.0.0',
    proxy: {
      // 当请求路径以 '/api' 开头时，将请求代理到指定的目标地址
      // http://192.168.144.241:2888
      '/api': {
        target: 'http://192.168.2.55:8050/', // 目标服务器地址
        changeOrigin: true, // 是否改变请求源地址
        // rewrite: (path) => path.replace(/^\/api/, '') // 重写路径，将 '/api' 前缀移除
      },
    }
  },
})